<?php
use_javascript('wemTabs.js','last');
use_stylesheet('list.css');
use_helper('toolsbar');
slot('Toolsbar');
   echo setToolbar('show','powerdev',$powerdev);
end_slot();

slot('PageTitle',$powerdev);
slot('Title',$powerdev);
?>

<div id="tabs">
    <ul>
        <li><a href='#tab-info'><span><?php echo $powerdev?> Info</span></a></li>      
        <li><a href='#tab-data'><span><?php echo $powerdev?> Data</span></a></li>
    </ul>
    
    <div id="tab-info">
        <table id="lista">
          <tbody>
            <tr class="odd">
              <th>Plant:</th>
              <td><?php echo $powerdev->getPlant() ?></td>
            </tr>
            <tr class="even">
              <th>Brand:</th>
              <td><?php echo $powerdev->getBrand() ?></td>
            </tr>
            <tr class="odd">
              <th>Model:</th>
              <td><?php echo $powerdev->getModel() ?></td>
            </tr>
            <tr class="even">
              <th>Serial:</th>
              <td><?php echo $powerdev->getSerial() ?></td>
            </tr>
            <tr class="odd">
              <th>Type:</th>
              <td><?php echo $powerdev->getType() ?></td>
            </tr>
            <tr class="even">
              <th>Subtype:</th>
              <td><?php echo $powerdev->getSubtype() ?></td>
            </tr>
            <tr class="odd">
              <th>Label:</th>
              <td><?php echo $powerdev->getLabel() ?></td>
            </tr>
            <tr class="even">
              <th>Source:</th>
              <td><?php echo $powerdev->getSource() ?></td>
            </tr>
            <tr class="odd">
              <th>Address:</th>
              <td><?php echo $powerdev->getAddress() ?></td>
            </tr>
            <tr class="even">
              <th>Source2:</th>
              <td><?php echo $powerdev->getSource2() ?></td>
            </tr>
            <tr class="odd">
              <th>Address2:</th>
              <td><?php echo $powerdev->getAddress2() ?></td>
            </tr>
     <?php if (!is_null( $powerdev->getPower())){ ?>       
            <tr class="even">
              <th>Power:</th>
              <td><?php echo $powerdev->getPower() ?></td>
            </tr>
     <?php } ?> 
            <tr class="even">
              <th>Quantity:</th>
              <td><?php echo $powerdev->getQuantity() ?></td>
            </tr>
            <tr class="odd">
              <th>Note:</th>
              <td><?php echo $powerdev->getNote() ?></td>
            </tr>
    <?php if (!is_null($powerdev->getSubplant()) and ($powerdev->getSubplant()<>"") ){ ?>       
            <tr class="even">
              <th>Subplant:</th>
              <td><?php echo $powerdev->getSubplant() ?></td>
            </tr>
    <?php } ?>        
          </tbody>
        </table>
    </div>
    
    <div id="tab-data">
  <?php if (isset($data)) { ?>
        <table id="lista">
            <thead>
                <tr>
                    <th>Label</th>
                    <th>Value</th>
                </tr>
                <tr>
                    <th class="order" colspan="2"><?php echo $data["Day"]." ".$data["Sample Time"]?></th>
                </tr>
            </thead>
            <tbody>
   <?php        $i=0;
                foreach ($data as $label=>$val){
                    if (($label<>"Day") and ($label<>"Sample Time")){
                        if (strpos($label, "_")!== FALSE){
                            $name=  substr($label,0, strpos($label, "_"));
                            $um=substr($label,strpos($label, "_")+1);
                        }else{
                            $name=$label;
                            $um=NULL;
                        }
                        $i++;
                        $odd = fmod($i, 2) ? 'even':'odd';?>
                        <tr class="<?php echo $odd?>">
                            <th><?php echo $name?></th>
                            <td><?php echo (isset($um))?$val." [".$um."]":$val?></td>
                        </tr>    
   <?php            } 
                }?>             
            </tbody>
        </table>
        
   <?php }else{ ?>   
        <div class="redlight"> Data not available for <?php echo $powerdev->getLabel()?></div>
   <?php } ?>     
    </div> 